/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* reverseList(struct ListNode* head) {
    struct ListNode* prev = NULL, *next = head;//定义新链表的两个指针
    while(next){
        struct ListNode* obj = next->next;//obj为原链表指针
        next->next = prev;
        prev = next;
        next = obj;
    }
    return prev;
}

//我的理解
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* reverseList(struct ListNode* head){
    if(head == NULL || head->next == NULL){
        return head;
    }
    struct ListNode* prev = NULL;
    struct ListNode* now = head;
    struct ListNode* next = now->next;
    while(next){
        now->next = prev;
        prev = now;
        now = next;
        next = next->next;
    }
    now->next = prev;
    return now;
}
/*给你单链表的头节点head，请你反转链表，并返回反转后的链表。*/